package com.mk.admin.service.impl;

import com.mk.admin.mapper.DoctorGuidanceTemplateMapper;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.entity.DoctorGuidanceTemplateEntity;
import com.mk.admin.model.query.DoctorGuidanceTemplateQuery;
import com.mk.admin.model.vo.DoctorGuidanceTemplateVo;
import com.mk.admin.service.DoctorGuidanceTemplateService;
import com.mk.admin.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DoctorGuidanceTemplateServiceImpl implements DoctorGuidanceTemplateService {
  @Autowired
  private DoctorGuidanceTemplateMapper doctorGuidanceTemplateMapper;
    @Override
    public ResultDto select(DoctorGuidanceTemplateQuery query) {
        DoctorGuidanceTemplateEntity entity= JSONCopy.copy(query,DoctorGuidanceTemplateEntity.class);
        return ResultDto.data(doctorGuidanceTemplateMapper.count(entity),doctorGuidanceTemplateMapper.select(entity));
    }

    @Override
    public ResultDto add(DoctorGuidanceTemplateVo doctorGuidanceTemplateVo) {
        DoctorGuidanceTemplateEntity entity= JSONCopy.copy(doctorGuidanceTemplateVo,DoctorGuidanceTemplateEntity.class);
        return ResultDto.data(doctorGuidanceTemplateMapper.insert(entity));
    }

    @Override
    public ResultDto update(DoctorGuidanceTemplateVo doctorGuidanceTemplateVo) {
        DoctorGuidanceTemplateEntity entity= JSONCopy.copy(doctorGuidanceTemplateVo,DoctorGuidanceTemplateEntity.class);
        return ResultDto.data(doctorGuidanceTemplateMapper.updateById(entity));
    }

    @Override
    public ResultDto delete(int id) {
        return ResultDto.data(doctorGuidanceTemplateMapper.deleteById(id));
    }

    @Override
    public ResultDto status(int id) {
        return ResultDto.data(doctorGuidanceTemplateMapper.status(id));
    }
}
